var MouseEventType = {
		MOUSE_LEFT_UP:10,
		MOUSE_LEFT_DOWN:20,
		MOUSE_RIGHT_UP:30,
		MOUSE_RIGHT_DOWN:40,
		MOUSE_ENTER:50,
		MOUSE_EXIT:60,
		MOUSE_MOVE:70
};

var DISTANCE_CALCULATOR_ECULID = new DistanceCalculator();
var DISTANCE_CALCULATOR_MOD_CHEB = new ModifiedChebyshevDistanceCalculator();

var DEBUG_CONSOLE;

var UNIT_DRAW_SIZE = 40;

var ANIMATION_WALK_FPS = 10;

// == sprite sheet crops: ==

// = human/skeleton: =
//UP - STAND:
var UNIT_HUMANOID_SPRITE_SHEET_CROP_0_0 = new ImgCrop(0, 0, -CANVAS_CELL_SIZE + CANVAS_CELL_SIZE/7, -2*CANVAS_CELL_SIZE, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
//UP - WALK:
var UNIT_HUMANOID_SPRITE_SHEET_CROP_0_1 = new ImgCrop(1*64, 0, -CANVAS_CELL_SIZE + CANVAS_CELL_SIZE/7, -2*CANVAS_CELL_SIZE, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_0_2 = new ImgCrop(2*64, 0, -CANVAS_CELL_SIZE + CANVAS_CELL_SIZE/7, -2*CANVAS_CELL_SIZE, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_0_3 = new ImgCrop(3*64, 0, -CANVAS_CELL_SIZE + CANVAS_CELL_SIZE/7, -2*CANVAS_CELL_SIZE, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_0_4 = new ImgCrop(4*64, 0, -CANVAS_CELL_SIZE + CANVAS_CELL_SIZE/7, -2*CANVAS_CELL_SIZE, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_0_5 = new ImgCrop(5*64, 0, -CANVAS_CELL_SIZE + CANVAS_CELL_SIZE/7, -2*CANVAS_CELL_SIZE, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_0_6 = new ImgCrop(6*64, 0, -CANVAS_CELL_SIZE + CANVAS_CELL_SIZE/7, -2*CANVAS_CELL_SIZE, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_0_7 = new ImgCrop(7*64, 0, -CANVAS_CELL_SIZE + CANVAS_CELL_SIZE/7, -2*CANVAS_CELL_SIZE, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_0_8 = new ImgCrop(8*64, 0, -CANVAS_CELL_SIZE + CANVAS_CELL_SIZE/7, -2*CANVAS_CELL_SIZE, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);

//LEFT - STAND:
var UNIT_HUMANOID_SPRITE_SHEET_CROP_1_0 = new ImgCrop(0, 64, -CANVAS_CELL_SIZE/2-CANVAS_CELL_SIZE/3, -2*CANVAS_CELL_SIZE-CANVAS_CELL_SIZE/8, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
//LEFT - WALK:
var UNIT_HUMANOID_SPRITE_SHEET_CROP_1_1 = new ImgCrop(1*64, 64, -CANVAS_CELL_SIZE/2-CANVAS_CELL_SIZE/3, -2*CANVAS_CELL_SIZE-CANVAS_CELL_SIZE/8, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_1_2 = new ImgCrop(2*64, 64, -CANVAS_CELL_SIZE/2-CANVAS_CELL_SIZE/3, -2*CANVAS_CELL_SIZE-CANVAS_CELL_SIZE/8, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_1_3 = new ImgCrop(3*64, 64, -CANVAS_CELL_SIZE/2-CANVAS_CELL_SIZE/3, -2*CANVAS_CELL_SIZE-CANVAS_CELL_SIZE/8, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_1_4 = new ImgCrop(4*64, 64, -CANVAS_CELL_SIZE/2-CANVAS_CELL_SIZE/3, -2*CANVAS_CELL_SIZE-CANVAS_CELL_SIZE/8, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_1_5 = new ImgCrop(5*64, 64, -CANVAS_CELL_SIZE/2-CANVAS_CELL_SIZE/3, -2*CANVAS_CELL_SIZE-CANVAS_CELL_SIZE/8, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_1_6 = new ImgCrop(6*64, 64, -CANVAS_CELL_SIZE/2-CANVAS_CELL_SIZE/3, -2*CANVAS_CELL_SIZE-CANVAS_CELL_SIZE/8, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_1_7 = new ImgCrop(7*64, 64, -CANVAS_CELL_SIZE/2-CANVAS_CELL_SIZE/3, -2*CANVAS_CELL_SIZE-CANVAS_CELL_SIZE/8, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_1_8 = new ImgCrop(8*64, 64, -CANVAS_CELL_SIZE/2-CANVAS_CELL_SIZE/3, -2*CANVAS_CELL_SIZE-CANVAS_CELL_SIZE/8, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);

//DOWN - STAND:
var UNIT_HUMANOID_SPRITE_SHEET_CROP_2_0 = new ImgCrop(0, 128, -CANVAS_CELL_SIZE + CANVAS_CELL_SIZE/7, -2*CANVAS_CELL_SIZE, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
//DOWN - WALK:
var UNIT_HUMANOID_SPRITE_SHEET_CROP_2_1 = new ImgCrop(1*64, 128, -CANVAS_CELL_SIZE + CANVAS_CELL_SIZE/7, -2*CANVAS_CELL_SIZE, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_2_2 = new ImgCrop(2*64, 128, -CANVAS_CELL_SIZE + CANVAS_CELL_SIZE/7, -2*CANVAS_CELL_SIZE, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_2_3 = new ImgCrop(3*64, 128, -CANVAS_CELL_SIZE + CANVAS_CELL_SIZE/7, -2*CANVAS_CELL_SIZE, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_2_4 = new ImgCrop(4*64, 128, -CANVAS_CELL_SIZE + CANVAS_CELL_SIZE/7, -2*CANVAS_CELL_SIZE, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_2_5 = new ImgCrop(5*64, 128, -CANVAS_CELL_SIZE + CANVAS_CELL_SIZE/7, -2*CANVAS_CELL_SIZE, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_2_6 = new ImgCrop(6*64, 128, -CANVAS_CELL_SIZE + CANVAS_CELL_SIZE/7, -2*CANVAS_CELL_SIZE, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_2_7 = new ImgCrop(7*64, 128, -CANVAS_CELL_SIZE + CANVAS_CELL_SIZE/7, -2*CANVAS_CELL_SIZE, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_2_8 = new ImgCrop(8*64, 128, -CANVAS_CELL_SIZE + CANVAS_CELL_SIZE/7, -2*CANVAS_CELL_SIZE, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);

//RIGHT - STAND:
var UNIT_HUMANOID_SPRITE_SHEET_CROP_3_0 = new ImgCrop(0, 192, -CANVAS_CELL_SIZE/2-CANVAS_CELL_SIZE/3, -2*CANVAS_CELL_SIZE-CANVAS_CELL_SIZE/8, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
//RIGHT - WALK:
var UNIT_HUMANOID_SPRITE_SHEET_CROP_3_1 = new ImgCrop(1*64, 192, -CANVAS_CELL_SIZE/2-CANVAS_CELL_SIZE/3, -2*CANVAS_CELL_SIZE-CANVAS_CELL_SIZE/8, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_3_2 = new ImgCrop(2*64, 192, -CANVAS_CELL_SIZE/2-CANVAS_CELL_SIZE/3, -2*CANVAS_CELL_SIZE-CANVAS_CELL_SIZE/8, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_3_3 = new ImgCrop(3*64, 192, -CANVAS_CELL_SIZE/2-CANVAS_CELL_SIZE/3, -2*CANVAS_CELL_SIZE-CANVAS_CELL_SIZE/8, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_3_4 = new ImgCrop(4*64, 192, -CANVAS_CELL_SIZE/2-CANVAS_CELL_SIZE/3, -2*CANVAS_CELL_SIZE-CANVAS_CELL_SIZE/8, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_3_5 = new ImgCrop(5*64, 192, -CANVAS_CELL_SIZE/2-CANVAS_CELL_SIZE/3, -2*CANVAS_CELL_SIZE-CANVAS_CELL_SIZE/8, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_3_6 = new ImgCrop(6*64, 192, -CANVAS_CELL_SIZE/2-CANVAS_CELL_SIZE/3, -2*CANVAS_CELL_SIZE-CANVAS_CELL_SIZE/8, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_3_7 = new ImgCrop(7*64, 192, -CANVAS_CELL_SIZE/2-CANVAS_CELL_SIZE/3, -2*CANVAS_CELL_SIZE-CANVAS_CELL_SIZE/8, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);
var UNIT_HUMANOID_SPRITE_SHEET_CROP_3_8 = new ImgCrop(8*64, 192, -CANVAS_CELL_SIZE/2-CANVAS_CELL_SIZE/3, -2*CANVAS_CELL_SIZE-CANVAS_CELL_SIZE/8, 64, 64, UNIT_DRAW_SIZE, UNIT_DRAW_SIZE);

// = arrows =
var UNIT_ARROW_SPRITE_SHEET_CROP = new ImgCrop(0, 0, 0, 0, 64, 64, CANVAS_CELL_SIZE, CANVAS_CELL_SIZE);

// == spritesheets: ==
var UNIT_HUMAN_SPRITE_SHEET_IMG = new Image();
UNIT_HUMAN_SPRITE_SHEET_IMG.src = "img/unit_human_sprite_sheet.png";

var UNIT_SKELETON_SPRITE_SHEET_IMG = new Image();
UNIT_SKELETON_SPRITE_SHEET_IMG.src = "img/unit_skeleton_sprite_sheet.png";

var ARROW_BLUE_LEFT_IMG = new Image();
ARROW_BLUE_LEFT_IMG.src = "img/unit_blue_left.png";

var ARROW_BLUE_RIGHT_IMG = new Image();
ARROW_BLUE_RIGHT_IMG.src = "img/unit_blue_right.png";

var ARROW_RED_LEFT_IMG = new Image();
ARROW_RED_LEFT_IMG.src = "img/unit_red_left.png";

var ARROW_RED_RIGHT_IMG = new Image();
ARROW_RED_RIGHT_IMG.src = "img/unit_red_right.png";

var OBSTACLE_SPRITE = new Image();
OBSTACLE_SPRITE.src = "img/obstacle.png";

var ANIMATION_BUNDLE_CREATOR = new AnimationBundleCreator();